/**
 * @function getCurTimeStamp 获取当前时间戳
 * @returns {Number} 当前时间的时间戳，秒级
 */
const getCurTimeStamp = () => {
    return new Date().getTime()
}

function format(shijian) {
    let date = new Date(shijian)
    var y = date.getFullYear()
    var m = date.getMonth() + 1
    m = m < 10 ? ('0' + m) : m
    var d = date.getDate()
    d = d < 10 ? ('0' + d) : d
    return y + '-' + m + '-' + d
}

/**
 * 计算两个时间相差是否在10分钟以内
 */
const timeDifference = (startTime, endTime) => {
    let diff  =startTime.getTime() - endTime.getTime();
    console.log(diff);
    console.log(diff<= 10 * 1000 * 60)
    return  diff<= 10 * 1000 * 60;
}

module.exports = {
    getCurTimeStamp,
    format,
    timeDifference
}
